package com.yunyi.action;

import com.github.pagehelper.PageInfo;
import com.yunyi.pojo.User;
import com.yunyi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 暴露接口
 *
 * @author yunyi
 */
@RestController
@RequestMapping("/user")
public class UserAction {

    @Autowired
    private UserService userService;

    @GetMapping("getUserById")
    public User getUserById(int id) {
        return userService.getUserWithAnnotationsById(id);
    }

    @GetMapping("getUserByIdWithPro")
    public User getUserByIdWithPropertiesFile(int id) {
        return userService.getUserById(id);
    }

    @GetMapping("getUserListWithPage")
    public List<User> getUserListWithPage(int pageNum, int pageSize) {
        return userService.getUserListWithPage(pageNum, pageSize);
    }

    @GetMapping("getUserListWithTotalPage")
    public PageInfo<User> getUserListWithTotalPage(int pageNum, int pageSize) {
        return userService.getUserListWithTotalPage(pageNum, pageSize);
    }
}
